package com.dandelion.manager.system.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dandelion.commons.annotation.SystemLog;
import com.dandelion.commons.constants.BaseConst;
import com.dandelion.commons.web.controller.BaseController;
import com.dandelion.commons.web.model.AjaxResponse;
import com.dandelion.manager.system.domain.Global;
import com.dandelion.manager.system.service.GlobalService;

@Controller
@RequestMapping("/manager/system/global")
public class GlobalController extends BaseController {

	@Autowired
	public GlobalService service ;
	
	/**
	 * 主页
	 * @return
	 */
	@RequestMapping(value="/main", method=RequestMethod.GET)
	public String main() {
		return viewName("main") ;
	}
	
	
	/**
	 * 添加
	 * @param dto
	 * @return
	 */
	@SystemLog(module=BaseConst.MODULE_SYSTEM+"全局参数", method="新增系统全局参数")
	@RequestMapping(value="/add", method=RequestMethod.POST)
	public @ResponseBody AjaxResponse add(Global dto) {
		return this.service.add(dto);
	}
	
	/**
	 * 删除
	 * @param ids 数组
	 * @return
	 */
	@SystemLog(module=BaseConst.MODULE_SYSTEM+"全局参数", method="删除系统全局参数")
	@RequestMapping(value="/delete", method=RequestMethod.POST)
	public @ResponseBody AjaxResponse delete(Long[] ids) {
		return this.service.deleteBatch(ids);
	}
	
	/**
	 * 修改
	 * @param dto
	 * @return
	 */
	@SystemLog(module=BaseConst.MODULE_SYSTEM+"全局参数", method="修改系统全局参数")
	@RequestMapping(value="/update", method=RequestMethod.POST)
	public @ResponseBody AjaxResponse update(Global dto) {
		return this.service.update(dto);
	}
	
	/**
	 * 根据ID获取数据
	 * @param id
	 * @return
	 */
	@SystemLog(module=BaseConst.MODULE_SYSTEM+"全局参数", method="加载系统全局参数")
	@RequestMapping(value="/get/{id}", method=RequestMethod.GET)
	public @ResponseBody Global get(@PathVariable Long id) {
		return this.service.get(id) ;
	}
	
	/**
	 * 查询所有
	 * @param dto
	 * @return
	 */
	@SystemLog(module=BaseConst.MODULE_SYSTEM+"全局参数", method="查询所有系统全局参数")
	@RequestMapping(value="/getAllList")
	public @ResponseBody List<Global> getAllList(Global dto) {
		return this.service.getAllList(dto) ;
	}
	
}
